<?php

class magazinesActions extends sfActions {

    public function executeIndex(sfWebRequest $request){

    }

    public function executeDetail(sfWebRequest $request){

    }

    public function executeShow_pdf(sfWebRequest $request){
        $id = $request->getParameter('id');
        $id = "pdfex.pdf";

        // being sure no other content wil be output

        $this->setLayout(false);
        sfConfig::set('sf_web_debug', false);

        $pdfpath = sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.'magazines'
                                    .DIRECTORY_SEPARATOR
                                    .$id;

        // check if the file exists
        $this->forward404Unless(file_exists($pdfpath));

        // Adding the file to the Response object
        $this->getResponse()->clearHttpHeaders();
        $this->getResponse()->setHttpHeader('Pragma: public', true);
        $this->getResponse()->setContentType('application/pdf');

        $this->getResponse()->sendHttpHeaders();
        $this->getResponse()->setContent(readfile($pdfpath));

        return sfView::NONE;
    }

}